<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">

<ui:include src="/WEB-INF/includes/head.xhtml">
    <ui:param name="pageTitle" value="Trips" />
</ui:include>
<h:body>
	<ui:include src="/WEB-INF/includes/menu.xhtml" />
	<h1>Trips</h1>
	<h:form id="form">

		<!-- Error messages -->
		<p:messages id="messages" closable="true" />
		
		<!-- User tickets table -->
		<p:dataTable var="trip" value="#{trips.trips}">
			<p:column headerText="Start">
				<h:outputText value="#{trip.start}" />
			</p:column>
			<p:column headerText="Trip ID">
				<h:outputText value="#{trip.id}" />
			</p:column>
			<p:column headerText="Route">
				<h:outputText value="#{trip.routeName}" />
			</p:column>
			<p:column headerText="Total seats">
				<h:outputText value="#{trip.seats}" />
			</p:column>
			<p:column headerText="Sell" style="width:4%">
				<p:commandButton id="sellButton" update=":sellTicketForm:display"
					oncomplete="PF('sellTicket').show()" icon="ui-icon-cart" title="Sell">
					<f:setPropertyActionListener target="#{sellTicket.tripID}"
						value="#{trip.id}" />
				</p:commandButton>
			</p:column>
		</p:dataTable>
	</h:form>

	<ui:include src="/WEB-INF/includes/sell-ticket.xhtml" />

</h:body>
</html>